<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer">
      <span class="todo-count">剩余<strong>{{ listCount }}</strong></span>
      <ul class="filters" @click="$emit('check',type)">
        <li>
          <a :class="{selected:type === 'all'}" href="#/" @click.prevent="type='all'">全部</a>
        </li>
        <li>
          <a :class="{selected:type === 'active'}" href="#/active" @click.prevent="type='active'">进行中</a>
        </li>
        <li>
          <a  :class="{selected:type === 'completed'}" href="#/completed" @click.prevent="type='completed'">已完成</a>
        </li>
      </ul>
      <button class="clear-completed" v-show="showClear" @click="Clear">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      required:true
    }
  },
  name: 'VueDemoTodoFooter',

  data() {
    return {
      type:'all'
    };
  },

  mounted() {
    
  },

  methods: {
    Clear(){
      this.$emit('ClearTask')
    }
  },
  computed:{
    listCount(){
      return this.list.length
    },
    showClear(){
      return this.list.some(item => item.isDone)
    }
  }
};
</script>

<style lang="scss" scoped>

</style>